function [y,phase] = generate_sin_wave( f, fs, num_samples, phase)
    t = 0:1/fs:(num_samples-1)/fs;
    y = sin(2*pi*f*t + phase);
    phase = phase + 2*pi*f*num_samples/fs;
end

